修改服务器访问默认端口,防止服务器被恶意访问。
steps:
1sudo vi /etc/ssh/sshd_config // 编辑配置文件,记录配置文件地址输入密码;这里注意重新打开一个窗口,经验之谈,防止忘记了无法登陆服务器。
下面是配置文件
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
# What ports, IPs and protocols we listen forPort 3389# Use these options to restrict which interfaces/protocols sshd will bind to#ListenAddress ::#ListenAddress 0.0.0.0Protocol 2# HostKeys for protocol version 2HostKey /etc/ssh/ssh_host_rsa_keyHostKey /etc/ssh/ssh_host_dsa_keyHostKey /etc/ssh/ssh_host_ecdsa_keyHostKey /etc/ssh/ssh_host_ed25519_key#Privilege Separation is turned on for securityUsePrivilegeSeparation yes # Lifetime and size of ephemeral version 1 server keyKeyRegenerationInterval 3600ServerKeyBits 1024 # LoggingLogLevel INFO # Authentication:LoginGraceTime 120StrictModes yes RSAAuthentication yesPubkeyAuthentication yes#AuthorizedKeysFile %h/.ssh/authorized_keys# Don't read the user's ~/.rhosts and ~/.shosts filesIgnoreRhosts yes# For this to work you will also need host keys in /etc/ssh_known_hostsRhostsRSAAuthentication no# similar for protocol version 2HostbasedAuthentication no# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication#IgnoreUserKnownHosts yes# To enable empty passwords, change to yes (NOT RECOMMENDED)PermitEmptyPasswords no# Change to yes to enable challenge-response passwords (beware issues with# some PAM modules and threads)ChallengeResponseAuthentication no# Change to no to disable tunnelled clear text passwords#KerberosOrLocalPasswd yes#KerberosTicketCleanup yes# GSSAPI options#GSSAPIAuthentication no#GSSAPICleanupCredentials yesX11Forwarding yesX11DisplayOffset 10PrintMotd noPrintLastLog yesTCPKeepAlive yes#UseLogin no#MaxStartups 10:30:60#Banner /etc/issue.net# Allow client to pass locale environment variablesAcceptEnv LANG LC_*Subsystem sftp /usr/lib/openssh/sftp-server# Set this to 'yes' to enable PAM authentication, account processing,# and session processing. If this is enabled, PAM authentication will# be allowed through the ChallengeResponseAuthentication and# PAM authentication via ChallengeResponseAuthentication may bypass# If you just want the PAM account and session checks to run without# and ChallengeResponseAuthentication to 'no'.UsePAM yesCiphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,blowfish-cbc,aes128-cbc,3des-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbcUseDNS noAddressFamily inetPermitRootLogin noSyslogFacility AUTHPRIVPasswordAuthentication noAllowUsers bean
修改端口之后重启ssh服务,执行以下命令:
|
|
重新打开一个终端窗口,登陆服务器;
- nginx 转发配置
|
|
防火墙基础配置
|
|
进入 iptables.up.rules文件编辑
|
|
防火墙规则编辑完成后,执行命令确认防火墙配置文件位置
|
|
建立成功后查看防火墙的状态是否成功启动
|
|
激活防火墙
|
|
创建shell脚本,自动启用防火墙
|
|
写入脚本
|
|
给脚本配置执行的权限
|
|
安装fail2ban安防模块
|
|
安装之后打开修改部分配置文件
|
|
查看fail2ban 是否在运行
|
|
开启/停止fail2ban
|
|
防火墙增加端口访问权限
|
|